<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text">
<script>
    /*按Enter进行搜索*/
    const inputEl = document.querySelector('input')
    inputEl.addEventListener('keyup',(event)=>{
        if(event.code === 'Enter'){
            console.log(event.currentTarget.value)
        }
    })
    /*按s，搜索框自动获取焦点*/
    document.addEventListener('keyup',(event)=>{
        /*用户按下了s*/
        if(event.code === 'KeyS'){
            /*input*/
            inputEl.focus()
        }
    })
</script>
</body>
</html>